require(['jquery', 'cookie', 'app', 'lay','base64'], function ($) {
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: [],
                th: {},
                ADD:{},
                User:{}
            }
            , created: function () {
                this.User=JSON.parse(getCookie("user"));
                this.loadPage()
            }
            , methods: {
                loadPage: function () {
                    var json = {};
                    json["APPID"] = "550e8400-e29b-41d4-a716-446655440000";
                    json["uuid"] = "1566381003886";
                    var re = playAjax("1574998957822", json);
                    var toolbar = [];
                    var where = [];
                    var mail={
                        "LIKE":"3",
                        "ZDNAME":"f_mail_status",
                        "ZDVAL":"1"
                    };
                    where.push(mail);
                    mail={
                        "LIKE":"3",
                        "ZDNAME":"f_mail_status",
                        "ZDVAL":"2"
                    };
                    where.push(mail);
                    mail={
                        "LIKE":"3",
                        "ZDNAME":"f_mail_status",
                        "ZDVAL":"3"
                    };
                    where.push(mail);
                    this.where=where;
                    toolbar[0] = {
                        "clas": "layui-btn-warm",
                        "eve": "PAYMENT",
                        "tit": "付款",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                debugger;
                                if(data[0].f_status==1){
                                    data[0].f_status=0;
                                }else if(data[0].f_status==0){
                                    data[0].f_status=1;
                                }
                                loadT();
                                var re = playAjax("1574998957830", data[0]);
                                closeLoad();
                                alr(re.title);
                                setTimeout(function () {
                                    dic.referXadmin();
                                }, 1500);
                            }
                        }
                    };
                    toolbar[1] = {
                        "clas": "layui-btn-normal",
                        "eve": "SALE",
                        "tit": "寄售",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                dic.th = data[0];
                                dic.th.f_text_img=Base64.decode(dic.th.f_text_img.replace(/ /g,"+"));
                                setTimeout(function () {
                                    editor1.txt.html("");
                                    editor1.txt.html(dic.th.f_text_img);
                                },800);
                                $("html,body").animate({scrollTop: $(".layui-tab-content").offset().top}, 500);
                                layui.use(['element'], function () {
                                    var element = layui.element;
                                    element.tabChange('docDemoTabBrief', '2');
                                });
                                $("#SCS").parent().html("<img style='width:80%' src='"+dic.th.f_shop_img+"'>");
                                setTimeout(function () {
                                    layui.use(['element'], function () {
                                        var form = layui.form;
                                        form.render();
                                    })
                                },1500);
                            }
                        }
                    };
                    toolbar[2] = {
                        "clas": "",
                        "eve": "CONVERT",
                        "tit": "兑换",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                dic.th = data[0];
                                dic.th.f_text_img=Base64.decode(dic.th.f_text_img.replace(/ /g,"+"));
                                setTimeout(function () {
                                    editor1.txt.html("");
                                    editor1.txt.html(dic.th.f_text_img);
                                },800);
                                $("html,body").animate({scrollTop: $(".layui-tab-content").offset().top}, 500);
                                layui.use(['element'], function () {
                                    var element = layui.element;
                                    element.tabChange('docDemoTabBrief', '2');
                                });
                                $("#SCS").parent().html("<img style='width:80%' src='"+dic.th.f_shop_img+"'>");
                                setTimeout(function () {
                                    layui.use(['element'], function () {
                                        var form = layui.form;
                                        form.render();
                                    })
                                },1500);
                            }
                        }
                    };
                    toolbar[3] = {
                        "clas": "",
                        "eve": "DATAILS",
                        "tit": "详情",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                dic.th = data[0];
                                dic.th.f_text_img=Base64.decode(dic.th.f_text_img.replace(/ /g,"+"));
                                setTimeout(function () {
                                    editor1.txt.html("");
                                    editor1.txt.html(dic.th.f_text_img);
                                },800);
                                $("html,body").animate({scrollTop: $(".layui-tab-content").offset().top}, 500);
                                layui.use(['element'], function () {
                                    var element = layui.element;
                                    element.tabChange('docDemoTabBrief', '2');
                                });
                                $("#SCS").parent().html("<img style='width:80%' src='"+dic.th.f_shop_img+"'>");
                                setTimeout(function () {
                                    layui.use(['element'], function () {
                                        var form = layui.form;
                                        form.render();
                                    })
                                },1500);
                            }
                        }
                    };
                    if (re.code == '0') {
                        bspVIEW($(".sa-table"), "1566381003885", JSON.parse(re.data), this.where, toolbar);
                    }
                },
                seachs: function () {
                    this.where = whereJSON($(".el-form"));
                    this.loadPage();
                },
                referXadmin: function () {
                    window.location.reload();
                }
            }
        });
        layui.use('form', function () {
            var form = layui.form;
            form.render();
        })
    });
});
var xhrOnProgress=function(fun) {
    xhrOnProgress.onprogress = fun; //绑定监听
    //使用闭包实现监听绑
    return function() {
        //通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
        var xhr = $.ajaxSettings.xhr();
        //判断监听函数是否为函数
        if (typeof xhrOnProgress.onprogress !== 'function')
            return xhr;
        //如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
        if (xhrOnProgress.onprogress && xhr.upload) {
            xhr.upload.onprogress = xhrOnProgress.onprogress;
        }
        return xhr;
    }
}